<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath=request.getScheme()+"//"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- 引入jquery.js -->
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/js/jquery-2.0.3.min.js"></script>
    <!-- 引入 echarts.js -->
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/js/highcharts.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/js/exporting.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/js/export-data.js"></script>
    <title>商品销售情况柱状图</title>
</head>
<body style="align: center; margin: 56px 0px 0px 25%;">
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="width: 500px; height: 400px;"></div>

</body>
<script type="text/javascript">
        $(function () {
            var chart= {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            };var title={
                text: '商品近日销售比较图（饼状图）'
            };var varsubtitle= {
                text: '会计部'
            };var vartooltip={
                pointFormat: '{series.name}: {point.percentage:.1f}%'
            };var varplotOptions={
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        connectorColor: '#000000',
                        //绑定饼图外围字段
                        format: '{point.name}: {point.y}',
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
                        }
                    },
                    //显示类别标识框
                    showInLegend: true
                }
            };
            var json = {};
            json.chart = chart;
            json.title = title;
            json.varsubtitle = varsubtitle;
            json.vartooltip =vartooltip;
            json.varplotOptions =varplotOptions;



            var series = [];
            var arr = {};
            arr.type = 'pie';
            arr.name = '销售比重';
            var data =[];var array =[];
            $.ajax({
                type:'post',
                url:'/echart/adminEachartzhu',
                success:function (data) {
                    for(var i=0;i<data.length;i++){
                        array.push([data[i].pname,data[i].is_hot]);
                    }
                    arr.data = array;
                    series.push(arr);
                    json.series = series;
                    $("#main").highcharts(json);
                }
            });

    });

</script>
</html>
